var websocket = null;
$(function () {
    if ('WebSocket' in window) {
        websocket = new WebSocket("ws://localhost:8088/websocket.do" );
        websocket.onmessage = function(e) {
            console.log(e.data);
        }
    } else {
        alert('当前浏览器 Not support websocket')
    }


    if (websocket.readyState = WebSocket.CONNECTING) {
        console.log("websocket正在连接！")
    }
    websocket.onopen = function () {
        if (websocket.readyState = WebSocket.CONNECTING) {
            console.log("websocket正在连接！")
        }
        if (websocket.readyState = WebSocket.OPEN) {
            console.log("websocket已经打开！")
        }
    }

    websocket.onmessage = function(e) {
        console.log(e.data);
        websocket.send("123456")
    }
    websocket.onclose = function () {
        if(websocket.readyState == WebSocket.CLOSED){
            console.log('连接已关闭')
        }
        alert("连接报错")
    }
    websocket.onerror = function () {
        alert("连接报错")
    }



})
function zhengce() {
    websocket.send("7878877")
}
